package com.qst.rongxiaoserver.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.Data;

import java.util.Date;

import static com.baomidou.mybatisplus.annotation.FieldFill.INSERT;

@TableName("tb_product")
@Data
public class ProductModel {
    @TableId(type = IdType.AUTO)
    private Integer id;
    private String title;

    @NotBlank(message = "价格不能为空")
    @Pattern(regexp = "^(([1-9]{1}\\d*)|(0{1}))(\\.\\d{1,2})?$", message = "请输入合理的价格，由数字组成，最多两位小数")
    private String price;
    @NotBlank(message = "内容不能为空")
    @Size(min = 10, max = 150, message = "内容长度在10-150之间")
    private String content;

    private String type;
    private String picture;
    @TableField(value = "create_time", fill = INSERT)
    private Date createTime;
    @TableField(value = "update_time", fill = INSERT)
    private Date updateTime;
    private Integer status = 1; // 是否上架 0 下架 1 上架

}
